<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>

    <body>

        <h1>Heading with a <span>span</span> element.</h1>
        <p>A paragraph with <span>one</span>, <span>two</span>
            spans.</p>

        <script>
            function byTagName(node, tagName) {
                // Your code here.
            }

            console.log(byTagName(document.body, "h1").length);
            // → 1
            console.log(byTagName(document.body, "span").length);
            // → 3
            let para = document.querySelector("p");
            console.log(byTagName(para, "span").length);
  // → 2
        </script>
    </body>

</html>